package bo2s.DAO;

import java.sql.Connection;
import java.sql.DriverManager;

import javax.naming.Context;
import javax.naming.InitialContext;
import javax.sql.DataSource;

 

public class ConnectionDB {
    
	public static Connection getConnection(){
		try{
			
			Class.forName("com.mysql.jdbc.Driver");
			Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/sprint1","root","");
			return  con;
		}catch(Exception e){
			 System.out.println("Database.getConnection() Error -->" + e.getMessage());
			return null;
		}
	}
//	public static Connection getConnection(){
//		try{
//			Context ctx=new InitialContext();
//			Context eCtx=(Context)ctx.lookup("java:comp/env");
//			DataSource ds=(DataSource)eCtx.lookup("java/mvc-pattern-db");
//			Connection con=ds.getConnection();
//			return con;
//		}catch(Exception e){
//			e.printStackTrace();
//			return null;
//		}
//	}
	public static void Close(Connection con){
		try{
			con.close();
		}catch(Exception e){
			e.printStackTrace();
		}
	}
}
